/* Copyright (c) 2010, Peter Lényi */
/* Licensed under The BSD License. */

package gem.apps.gfs2.engine.entity;

/**
 * Entity Class Settings encapsulates application settings.
 * 
 * @author Peter Lényi
 * @version 20100515F
 */
public class Settings
{
    private static Settings instance = null;

    /**
     * title
     * motto
     * hostName
     * ownerEMail
     * owner
     */
    
    private String title;
    private String motto;
    private String hostName;
    private String ownerEMail;

    public static Settings getInstance(String title, String motto, String hostName, String ownerEMail) {
        if (instance == null) {
            instance = new Settings(title, motto, hostName, ownerEMail);
        }
        return instance;
    }

    private Settings(String title, String motto, String hostName, String ownerEMail) {
        setTitle(title);
        setMotto(motto);
        setHostName(hostName);
        setOwnerEMail(ownerEMail);
    }

    public String getHostName() {
        return hostName;
    }

    public void setHostName(String hostName) {
        if (hostName == null) {
            throw new NullPointerException("Parameter hostName is null.");
        }
        this.hostName = hostName;
    }

    public String getMotto() {
        return motto;
    }

    public void setMotto(String motto) {
        if (motto == null) {
            throw new NullPointerException("Parameter motto is null.");
        }
        this.motto = motto;
    }

    public String getOwnerEMail() {
        return ownerEMail;
    }

    public void setOwnerEMail(String ownerEMail) {
        if (ownerEMail == null) {
            throw new NullPointerException("Parameter ownerEMail is null.");
        }
        this.ownerEMail = ownerEMail;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        if (title == null) {
            throw new NullPointerException("Parameter title is null.");
        }
        this.title = title;
    }

    @Override
    public boolean equals(Object o) {
        boolean equal = false;
        if (o != null && o instanceof Settings) {
            Settings s = (Settings) o;
            if (this == s) {
                equal = true;
            }
        }
        return equal;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0);
        hash = 89 * hash + (this.motto != null ? this.motto.hashCode() : 0);
        hash = 89 * hash + (this.hostName != null ? this.hostName.hashCode() : 0);
        hash = 89 * hash + (this.ownerEMail != null ? this.ownerEMail.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "GFS2:Settings";
    }
}
